package com.example.practice;


import android.os.Bundle;
import android.support.design.widget.TabLayout;
import android.support.v4.app.Fragment;
import android.support.v4.view.ViewPager;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import java.util.ArrayList;
import java.util.List;


/**
 * A simple {@link Fragment} subclass.
 */
public class Fragment_5 extends Fragment {

    private View view;
    private TabLayout tl5;
    private ViewPager vp5;
    private List<Fragment> fragmentList=new ArrayList<>();

    public Fragment_5() {
        // Required empty public constructor
    }


    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        // Inflate the layout for this fragment
        view=inflater.inflate(R.layout.fragment_5, container, false);
        initView();
        return view;
    }

    private void initView() {
        tl5=view.findViewById(R.id.tl5);
        vp5=view.findViewById(R.id.vp5);
        //添加ViewPager
        fragmentList.add(new Fragment4());
        fragmentList.add(new Fragment5());
        FragmentAdpter2 fragmentPagerAdapter = new FragmentAdpter2(getChildFragmentManager(), fragmentList);
        vp5.setAdapter(fragmentPagerAdapter);
        vp5.setCurrentItem(0);
        tl5.setupWithViewPager(vp5);
    }

}
